CC=gcc
#CC=arm-none-linux-gnueabi-gcc
AFLAGS= -c -g
LDFLAGS= -lpthread -lpaho-mqtt3c -lm
AFLAGS += -I paho/include
LDFLAGS += -L paha/lib
OBJS = main.o  mqtt.o server.o msg_handler.o serial.o cJSON.o
 
smart_home :$(OBJS)
	$(CC) -o $@ $^ $(LDFLAGS)

dep_files := $(foreach f,$(OBJS),.$(f).d)
dep_files := $(wildcard $(dep_files))

ifneq ($(dep_files),)
  include $(dep_files)
endif

$(OBJS):%.o:%.c
	$(CC) -Wp,-MD,.$@.d $(AFLAGS) $< -o $@

.PHONY:clean lib
clean:
	rm *.o smart_home

lib:
	ar crs libmylib.a 
#gcc main.c -o server -L.. -lmylib -lpthread
